package pl.edu.pk.cc.client.admin;

import pl.edu.pk.cc.client.CCIndex;
import pl.edu.pk.cc.client.CCPage;
import pl.edu.pk.cc.common.dto.CCWorkerDTO;

public class CCAdminContent {
	private static CCWorkerDTO worker;

	public static String dodajMenu(int par){
		String str = "<div id='success'>";
		if(par == 1){
			str += "<h2>Pomyslnie dodano pracownika</h2>";
		}
		else if(par == 2){
			str += "<h2>Nie dodano</h2>";
		}
		else if(par == 3){
			str += "<h2>Uzytkownik juz istnieje</h2>";
		}
		else if(par == 4){
			str += "<h2>Nie podano wszystkich danych!</h2>";
		}
		else if(par == 5){
			str += "<h2>Bledny format daty</h2>";
		}
		else if(par == 6){
			str += "<h2>Bledny format licby (pesel, dlugosc,wynagrodzenie)</h2>";
		}
		else{
			str+= "";
		}
		str += "</div><form action='CCAdminFunctions' method='post'>"
				+ "Nazwa uzytkownika:<br /><input id='username' name='username' type='text' size=40 /><br />"
				+ "E-mail:<br /><input id='email' name='email' type='text' size=40 /><br />"
				+ "Imie:<br /><input id='name' name='name' type='text' size=40 /><br />"
				+ "Nazwisko:<br /><input id='surname' name='surname' type='text' size=40 /><br />"
				+ "Adres:<br /><input id='address' name='address' type='text' size=40 /><br />"
				+ "PESEL:<br /><input id='pesel' name='pesel' type='text' size=40 /><br />"
				+ "Data urodzenia:<br /><input id='birthdate' name='birthdate' type='text' size=40 /><br />"
				+ "Employment: <br />"
				+ "Data rozpoczecia:<br /><input id='startDate' name='startDate' type='text' size=40 /><br />"
				+ "Dlugosc (m-ce):<br /><input id='lenght' name='lenght' type='text' size=40 /><br />"
				+ "Wynagrodzenie:<br /><input id='salary' name='salary' type='text' size=40 /><br />"
				+ "<select id='perm' name='perm'>"
				+ "<option value='user'>User</option>"
				+ "<option value='admin'>Admin</option>"
				+ "<option value='chief'>Chief</option>"
				+ "</select>"
				+ "<input id='type' name='type' type='hidden' value='dodaj' />"
				+ "<input type='submit' value='Dodaj' />"
				+ "</form>"
				+ "<script src='http://code.jquery.com/jquery-1.9.1.js'></script>"
				+"<script src='http://code.jquery.com/ui/1.10.3/jquery-ui.js'></script>"
				+ "<script src='calendar.js' ></script>";

		return str;
	}

	public static String modyfikujMenu(int step,int par){
		String str = "<div id='success'>";
		switch(step){
		case 0:
			if(par == 2){
				str += "<h2>Nie znaleziono uzytkownika</h2>";
			}
			else if( par == 3){
				str += "<h2>Pomyslnie zmodyfikowano uzytkownika</h2>";
			}
			else if( par == 7){
				str += "<h2>Pomyslnie zresetowano haslo uzytkownika</h2>";
			}
			else {
				str += "";
			}
			str += "</div><form action='CCAdminFunctions' method='post'>"
					+ "Wpisz nazwe uzytkownika ktorego chcesz edytowac:<br />"
					+ "<input id='username' name='username' type='text' size=30 /><br />"
					+ "<input id='type' name='type' type='hidden' value='wyszukaj' />"
					+ "<input type='submit' value='wyszukaj' />"
					+ "</form>";
			break;
		case 1:
			if(par == 1){
				str += "<h2>Znaleziono uzytkownika</h2>";
			}
			else if (par == 4){
				str += "<h2>Nie wypelniono wszystkich pol</h2>";
			}
			else if(par == 5){
				str += "<h2>Bledny format daty</h2>";
			}
			else if(par == 6){
				str += "<h2>Bledny format licby (pesel, dlugosc,wynagrodzenie)</h2>";
			}
			else {
				str += "";
			}
			str += "</div><form action='CCAdminFunctions' method='post'>"
					+ "<input id='username' name='username' type='hidden' value='" + worker.getLogin().getUsername() +"' />"
					+ "E-mail:<br /><input id='email' name='email' type='text' size=40 value='"+worker.getLogin().getEmail()+"' /><br />"
					+ "Imie:<br /><input id='name' name='name' type='text' size=40 value='"+worker.getName()+"' /><br />"
					+ "Nazwisko:<br /><input id='surname' name='surname' type='text' size=40 value='"+worker.getSurname()+"' /><br />"
					+ "Adres:<br /><input id='address' name='address' type='text' size=40 value='"+worker.getAddress()+"' /><br />"
					+ "PESEL:<br /><input id='pesel' name='pesel' type='text' size=40 value='"+worker.getPesel()+"' /><br />"
					+ "Data urodzenia:<br /><input id='birthdate' name='birthdate' type='text' size=40 value='"+worker.getBirthdate()+"' /><br />"
					+ "Employment: <br />"
					+ "Data rozpoczecia:<br /><input id='startDate' name='startDate' type='text' size=40 value='"+worker.getEmp().getStartDate()+"' /><br />"
					+ "Dlugosc (m-ce):<br /><input id='lenght' name='lenght' type='text' size=40 value='"+worker.getEmp().getLenght()+"' /><br />"
					+ "Wynagrodzenie:<br /><input id='salary' name='salary' type='text' size=40 value='"+worker.getEmp().getSalary()+"' /><br />"
					+ "<select id='perm' name='perm'>"
					+ "<option value='user'>User</option>"
					+ "<option value='admin'>Admin</option>"
					+ "<option value='chief'>Chief</option>"
					+ "</select>"
					+ "<input id='type' name='type' type='hidden' value='modyfikuj' />"
					+ "<input type='submit' value='Zmien' />"
					+ "</form>"
					+ "<form action='CCAdminFunctions' method='post'>"
					+ "<input id='type' name='type' type='hidden' value='zmien_usera' />"
					+ "<input type='submit' value='Wybierz innego usera' />"
					+ "</form>"
					+ "</form>"
					+ "<form action='CCAdminFunctions' method='post'>"
					+ "<input id='type' name='type' type='hidden' value='haslo' />"
					+ "<input type='submit' value='Resetuj haslo' />"
					+ "</form>"
					+ "<script src='http://code.jquery.com/jquery-1.9.1.js'></script>"
					+"<script src='http://code.jquery.com/ui/1.10.3/jquery-ui.js'></script>"
					+ "<script src='calendar.js' ></script>";
			CCPage.setStep(0);
			break;
		}
		return str;
	}

	public static String usunMenu(int step, int par){
		String str ="<div id='success'>";
		switch(step){
		case 0:
			if( par == 2){
				str += "<h2>Nie znaleziono uzytkownika</h2>";
			}
			else if( par == 3){
				str += "<h2>Pomyslnie usunieto uzytkownika</h2>";
			}
			else {
				str += "";
			}
			str += "</div>Wpisz nazwe uzytkownika ktorego chcesz usunac: "
					+ "<form action='CCAdminFunctions' method='post'>"
					+ "<input id='username' name='username' type='text' size=30 /><br />"
					+ "<input id='type' name='type' type='hidden' value='usun' />"
					+ "<input type='submit' value='usun' />"
					+ "</form>";
			break;
		case 1:
			if(par == 1){
				str += "<h2>Znaleziono uzytkownika</h2>";
			}
			else {
				str += "";
			}
			str += "</div>Usuwasz uzytkownika: <font color='red'>" +worker.getLogin().getUsername() + "</font><br />"
			+ "Potwierdzasz? "
			+ "<form action='CCAdminFunctions' method='post'>"
			+ "<input id='type' name='type' type='hidden' value='usun_t' />"
			+ "<input type='submit' value='tak(usun)' />"
			+ "</form>"
			+ "<form action='CCAdminFunctions' method='post'>"
			+ "<input id='type' name='type' type='hidden' value='usun_n' />"
			+ "<input type='submit' value='nie(wybierz innego)' />"
			+ "</form>";
			break;
		}
		return str;
	}

	public static String wgrajUsersMenu(int par){
		String str = "<div id='success'>";
		if(par == 1){
			str += "<h2>Pomyslnie wgrano liste klientow</h2>";
		}
		else if(par ==1){
			str += "<h2>Nieprawidlowy format pliku</h2>";
		}
		else if(par ==3){
			str += "<h2>Zly format daty w pliku</h2>";
		}
		else {
			str += "";
		}
		str += "</div>"
				+ "<form action='CCAdminFunctions' method='post' enctype='multipart/form-data'>"
				+ "Wybierz plik z lista klientow do wczytania: <br />"
				+ "Format pliku: <br />"
				+ "<h4>imie,nazwisko,numer_tel(bez myslinikow),data_urodzenia(YYYY-MM-DD),adres;</h4>"
				+ "<input id='type' name='type' type='hidden' value='users' />"
				+ "<input id='file' name='file' type='file' />"
				+ "<input type='submit' value='Wgraj' />"
				+ "</form>";
		return str;
	}
	
	public static String wgrajSkrypt(int par){
		String str = "<div id='success'>";
		if(par == 1){
			str += "<h2>Pomyslnie wgrano skrypt</h2>";
		}
		else if(par == 2){
			str += "<h2>Nie udalo sie wgrac skryptu</h2>";
		}
		else {
			str +="";
		}
		str +="</div>"
				+ "<form action='CCAdminFunctions' method='post' enctype='multipart/form-data'>"
				+ "Wybierz plik ze skryptem do wczytania: <br />"
				+ "<input id='type' name='type' type='hidden' value='script' />"
				+ "<input id='file' name='file' type='file' /><br />"
				+ "Typ skryptu: <br />"
				+ "<select id='type' name='type'>"
				+ "<option value='sales'>Sprzedaz</option>"
				+ "<option value='agreement'>Umowy</option>"
				+ "</select><br />"
				+ "Zgoda: <input id='accept' name='accept' type='checkbox' value='yes'/><br />"
				+ "<input type='submit' value='Wgraj' />"
				+ "</form>";
		
		return str;
	}
	public static void setWorkerToEdit(CCWorkerDTO worker_s){
		worker = worker_s;
	}

}
